import java.util.Arrays;
import java.util.Scanner;

class PersonSortable implements Comparable<PersonSortable>{
	private String name;
	private int age;
	public PersonSortable(String name,int age){
		this.name = name;
		this.age = age;
	}
	public String toString() {
		return  name + "-" + age ;
	}
	public int compareTo(PersonSortable other){
		if(this.name.compareTo(other.name)>0) 	return 1;
		if(this.name.compareTo(other.name)<0)	return -1;
		else{
			if(this.age>other.age)	return 1;
			if(this.age<other.age)	return -1;
		}
		return 0;
	}
}

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n;
		n = in.nextInt();
		PersonSortable[] person = new PersonSortable[n];
		for(int i=0;i<n;i++){
			person[i] = new PersonSortable(in.next(),in.nextInt());
		}
		Arrays.sort(person);
		for(PersonSortable e : person){
			System.out.println(e);
		}
		System.out.println(Arrays.toString(PersonSortable.class.getInterfaces()));
	}
}